# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=ncdu2
pkgver=2.1.2
pkgrel=0
pkgdesc="Disk usage analyzer with an ncurses interface"
url="https://dev.yorhel.nl/ncdu"
license="MIT"
arch="x86_64 aarch64" # Limited by zig aport
makedepends="chrpath zig ncurses-dev"
subpackages="$pkgname-doc"
source="https://dev.yorhel.nl/download/ncdu-$pkgver.tar.gz
	pie-build.patch
	"
builddir="$srcdir/ncdu-$pkgver"
replaces=ncdu

# We may want other than "baseline" for other targets, when enabled by zig
case "$CARCH" in
	aarch64|x86_64) cputarget=baseline ;;
esac

build() {
	zig build -Drelease-safe ${cputarget:+-Dcpu="$cputarget"}
}

check() {
	zig build test
}

package() {
	install -Dm755 zig-out/bin/ncdu "$pkgdir"/usr/bin/ncdu
	chrpath -d "$pkgdir"/usr/bin/ncdu

	make install-doc PREFIX="$pkgdir/usr"

	install -Dm644 LICENSES/MIT.txt "$pkgdir"/usr/share/licenses/$pkgname/LICENSE
}

sha512sums="
ff48f2b9625e1aba29e5598051d16c4b5dc1a634fab897709226dd69d3b48031e6e62527c8514ec4753874d2d96800e538d6ad90b4a5f9851410d10579ccc67c  ncdu-2.1.2.tar.gz
25bc148b8bf9b33abab17ece35ea4f9fb657078438154b57f6c53d41e6e28487dce9e14bcc124cd77a9235ec3767bf31df2482ccde11b1d5d1ec35fd8a464e32  pie-build.patch
"
